<?php
require_once 'config.php';

$id = '';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
}
$page = PGlobal::getLayoutTemplate();

$hangsx = new HangSx();
$box = new Template(TEMPLATE_DIR . 'home-dienthoai-box.html');
$tenhang = $hangsx->executeScalar('SELECT tenhsx FROM hangsx WHERE mahsx=:id', array('id' => $id));
$box['title'] = 'Điện thoại ' . $tenhang;
$data = $hangsx->run('SELECT madt AS pid, tendt AS pname, giadt AS pprice, hinhdt as pimgurl FROM dienthoai WHERE mahsx=:id', array('id' => $id));
if (count($data) > 0) {
    foreach($data as $row) {
        $box['dienthoai-box-item'] .= PGlobal::getInstance()->renderBoxPhone($row);
    }
}

$page['content'] = $box->render();


echo $page->render();

